#pragma once
// MESSAGE TANK_CTL PACKING

#define MAVLINK_MSG_ID_TANK_CTL 12918


typedef struct __mavlink_tank_ctl_t {
 float speed; /*<  float*/
 float cur_position; /*<  float*/
 float target_position; /*<  float*/
 uint8_t motor_engage; /*<  uint8_t*/
 uint8_t valve_ctrl; /*<  uint8_t*/
 uint8_t fan_engage; /*<  uint8_t*/
} mavlink_tank_ctl_t;

#define MAVLINK_MSG_ID_TANK_CTL_LEN 15
#define MAVLINK_MSG_ID_TANK_CTL_MIN_LEN 15
#define MAVLINK_MSG_ID_12918_LEN 15
#define MAVLINK_MSG_ID_12918_MIN_LEN 15

#define MAVLINK_MSG_ID_TANK_CTL_CRC 37
#define MAVLINK_MSG_ID_12918_CRC 37



#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_TANK_CTL { \
    12918, \
    "TANK_CTL", \
    6, \
    {  { "speed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_tank_ctl_t, speed) }, \
         { "cur_position", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_tank_ctl_t, cur_position) }, \
         { "target_position", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_tank_ctl_t, target_position) }, \
         { "motor_engage", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_tank_ctl_t, motor_engage) }, \
         { "valve_ctrl", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_tank_ctl_t, valve_ctrl) }, \
         { "fan_engage", NULL, MAVLINK_TYPE_UINT8_T, 0, 14, offsetof(mavlink_tank_ctl_t, fan_engage) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_TANK_CTL { \
    "TANK_CTL", \
    6, \
    {  { "speed", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_tank_ctl_t, speed) }, \
         { "cur_position", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_tank_ctl_t, cur_position) }, \
         { "target_position", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_tank_ctl_t, target_position) }, \
         { "motor_engage", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_tank_ctl_t, motor_engage) }, \
         { "valve_ctrl", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_tank_ctl_t, valve_ctrl) }, \
         { "fan_engage", NULL, MAVLINK_TYPE_UINT8_T, 0, 14, offsetof(mavlink_tank_ctl_t, fan_engage) }, \
         } \
}
#endif

/**
 * @brief Pack a tank_ctl message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param speed  float
 * @param cur_position  float
 * @param target_position  float
 * @param motor_engage  uint8_t
 * @param valve_ctrl  uint8_t
 * @param fan_engage  uint8_t
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_tank_ctl_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               float speed, float cur_position, float target_position, uint8_t motor_engage, uint8_t valve_ctrl, uint8_t fan_engage)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_TANK_CTL_LEN];
    _mav_put_float(buf, 0, speed);
    _mav_put_float(buf, 4, cur_position);
    _mav_put_float(buf, 8, target_position);
    _mav_put_uint8_t(buf, 12, motor_engage);
    _mav_put_uint8_t(buf, 13, valve_ctrl);
    _mav_put_uint8_t(buf, 14, fan_engage);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TANK_CTL_LEN);
#else
    mavlink_tank_ctl_t packet;
    packet.speed = speed;
    packet.cur_position = cur_position;
    packet.target_position = target_position;
    packet.motor_engage = motor_engage;
    packet.valve_ctrl = valve_ctrl;
    packet.fan_engage = fan_engage;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TANK_CTL_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_TANK_CTL;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_TANK_CTL_MIN_LEN, MAVLINK_MSG_ID_TANK_CTL_LEN, MAVLINK_MSG_ID_TANK_CTL_CRC);
}

/**
 * @brief Pack a tank_ctl message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param speed  float
 * @param cur_position  float
 * @param target_position  float
 * @param motor_engage  uint8_t
 * @param valve_ctrl  uint8_t
 * @param fan_engage  uint8_t
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_tank_ctl_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   float speed,float cur_position,float target_position,uint8_t motor_engage,uint8_t valve_ctrl,uint8_t fan_engage)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_TANK_CTL_LEN];
    _mav_put_float(buf, 0, speed);
    _mav_put_float(buf, 4, cur_position);
    _mav_put_float(buf, 8, target_position);
    _mav_put_uint8_t(buf, 12, motor_engage);
    _mav_put_uint8_t(buf, 13, valve_ctrl);
    _mav_put_uint8_t(buf, 14, fan_engage);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_TANK_CTL_LEN);
#else
    mavlink_tank_ctl_t packet;
    packet.speed = speed;
    packet.cur_position = cur_position;
    packet.target_position = target_position;
    packet.motor_engage = motor_engage;
    packet.valve_ctrl = valve_ctrl;
    packet.fan_engage = fan_engage;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_TANK_CTL_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_TANK_CTL;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_TANK_CTL_MIN_LEN, MAVLINK_MSG_ID_TANK_CTL_LEN, MAVLINK_MSG_ID_TANK_CTL_CRC);
}

/**
 * @brief Encode a tank_ctl struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param tank_ctl C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_tank_ctl_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_tank_ctl_t* tank_ctl)
{
    return mavlink_msg_tank_ctl_pack(system_id, component_id, msg, tank_ctl->speed, tank_ctl->cur_position, tank_ctl->target_position, tank_ctl->motor_engage, tank_ctl->valve_ctrl, tank_ctl->fan_engage);
}

/**
 * @brief Encode a tank_ctl struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param tank_ctl C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_tank_ctl_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_tank_ctl_t* tank_ctl)
{
    return mavlink_msg_tank_ctl_pack_chan(system_id, component_id, chan, msg, tank_ctl->speed, tank_ctl->cur_position, tank_ctl->target_position, tank_ctl->motor_engage, tank_ctl->valve_ctrl, tank_ctl->fan_engage);
}

/**
 * @brief Send a tank_ctl message
 * @param chan MAVLink channel to send the message
 *
 * @param speed  float
 * @param cur_position  float
 * @param target_position  float
 * @param motor_engage  uint8_t
 * @param valve_ctrl  uint8_t
 * @param fan_engage  uint8_t
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_tank_ctl_send(mavlink_channel_t chan, float speed, float cur_position, float target_position, uint8_t motor_engage, uint8_t valve_ctrl, uint8_t fan_engage)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_TANK_CTL_LEN];
    _mav_put_float(buf, 0, speed);
    _mav_put_float(buf, 4, cur_position);
    _mav_put_float(buf, 8, target_position);
    _mav_put_uint8_t(buf, 12, motor_engage);
    _mav_put_uint8_t(buf, 13, valve_ctrl);
    _mav_put_uint8_t(buf, 14, fan_engage);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TANK_CTL, buf, MAVLINK_MSG_ID_TANK_CTL_MIN_LEN, MAVLINK_MSG_ID_TANK_CTL_LEN, MAVLINK_MSG_ID_TANK_CTL_CRC);
#else
    mavlink_tank_ctl_t packet;
    packet.speed = speed;
    packet.cur_position = cur_position;
    packet.target_position = target_position;
    packet.motor_engage = motor_engage;
    packet.valve_ctrl = valve_ctrl;
    packet.fan_engage = fan_engage;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TANK_CTL, (const char *)&packet, MAVLINK_MSG_ID_TANK_CTL_MIN_LEN, MAVLINK_MSG_ID_TANK_CTL_LEN, MAVLINK_MSG_ID_TANK_CTL_CRC);
#endif
}

/**
 * @brief Send a tank_ctl message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_tank_ctl_send_struct(mavlink_channel_t chan, const mavlink_tank_ctl_t* tank_ctl)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_tank_ctl_send(chan, tank_ctl->speed, tank_ctl->cur_position, tank_ctl->target_position, tank_ctl->motor_engage, tank_ctl->valve_ctrl, tank_ctl->fan_engage);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TANK_CTL, (const char *)tank_ctl, MAVLINK_MSG_ID_TANK_CTL_MIN_LEN, MAVLINK_MSG_ID_TANK_CTL_LEN, MAVLINK_MSG_ID_TANK_CTL_CRC);
#endif
}

#if MAVLINK_MSG_ID_TANK_CTL_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This variant of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_tank_ctl_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  float speed, float cur_position, float target_position, uint8_t motor_engage, uint8_t valve_ctrl, uint8_t fan_engage)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;
    _mav_put_float(buf, 0, speed);
    _mav_put_float(buf, 4, cur_position);
    _mav_put_float(buf, 8, target_position);
    _mav_put_uint8_t(buf, 12, motor_engage);
    _mav_put_uint8_t(buf, 13, valve_ctrl);
    _mav_put_uint8_t(buf, 14, fan_engage);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TANK_CTL, buf, MAVLINK_MSG_ID_TANK_CTL_MIN_LEN, MAVLINK_MSG_ID_TANK_CTL_LEN, MAVLINK_MSG_ID_TANK_CTL_CRC);
#else
    mavlink_tank_ctl_t *packet = (mavlink_tank_ctl_t *)msgbuf;
    packet->speed = speed;
    packet->cur_position = cur_position;
    packet->target_position = target_position;
    packet->motor_engage = motor_engage;
    packet->valve_ctrl = valve_ctrl;
    packet->fan_engage = fan_engage;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_TANK_CTL, (const char *)packet, MAVLINK_MSG_ID_TANK_CTL_MIN_LEN, MAVLINK_MSG_ID_TANK_CTL_LEN, MAVLINK_MSG_ID_TANK_CTL_CRC);
#endif
}
#endif

#endif

// MESSAGE TANK_CTL UNPACKING


/**
 * @brief Get field speed from tank_ctl message
 *
 * @return  float
 */
static inline float mavlink_msg_tank_ctl_get_speed(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  0);
}

/**
 * @brief Get field cur_position from tank_ctl message
 *
 * @return  float
 */
static inline float mavlink_msg_tank_ctl_get_cur_position(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  4);
}

/**
 * @brief Get field target_position from tank_ctl message
 *
 * @return  float
 */
static inline float mavlink_msg_tank_ctl_get_target_position(const mavlink_message_t* msg)
{
    return _MAV_RETURN_float(msg,  8);
}

/**
 * @brief Get field motor_engage from tank_ctl message
 *
 * @return  uint8_t
 */
static inline uint8_t mavlink_msg_tank_ctl_get_motor_engage(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  12);
}

/**
 * @brief Get field valve_ctrl from tank_ctl message
 *
 * @return  uint8_t
 */
static inline uint8_t mavlink_msg_tank_ctl_get_valve_ctrl(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  13);
}

/**
 * @brief Get field fan_engage from tank_ctl message
 *
 * @return  uint8_t
 */
static inline uint8_t mavlink_msg_tank_ctl_get_fan_engage(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  14);
}

/**
 * @brief Decode a tank_ctl message into a struct
 *
 * @param msg The message to decode
 * @param tank_ctl C-struct to decode the message contents into
 */
static inline void mavlink_msg_tank_ctl_decode(const mavlink_message_t* msg, mavlink_tank_ctl_t* tank_ctl)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    tank_ctl->speed = mavlink_msg_tank_ctl_get_speed(msg);
    tank_ctl->cur_position = mavlink_msg_tank_ctl_get_cur_position(msg);
    tank_ctl->target_position = mavlink_msg_tank_ctl_get_target_position(msg);
    tank_ctl->motor_engage = mavlink_msg_tank_ctl_get_motor_engage(msg);
    tank_ctl->valve_ctrl = mavlink_msg_tank_ctl_get_valve_ctrl(msg);
    tank_ctl->fan_engage = mavlink_msg_tank_ctl_get_fan_engage(msg);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_TANK_CTL_LEN? msg->len : MAVLINK_MSG_ID_TANK_CTL_LEN;
        memset(tank_ctl, 0, MAVLINK_MSG_ID_TANK_CTL_LEN);
    memcpy(tank_ctl, _MAV_PAYLOAD(msg), len);
#endif
}
